package com.swust.course.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.swust.common.log.annotation.Log;
import com.swust.common.log.enums.BusinessType;
import com.swust.common.security.annotation.RequiresPermissions;
import com.swust.course.domain.CourseTechClass;
import com.swust.course.service.ICourseTechClassService;
import com.swust.common.core.web.controller.BaseController;
import com.swust.common.core.web.domain.AjaxResult;
import com.swust.common.core.utils.poi.ExcelUtil;
import com.swust.common.core.web.page.TableDataInfo;

/**
 * 授课班级对应Controller
 * 
 * @author LiuShuai
 * @date 2024-04-05
 */
@RestController
@RequestMapping("/courseTechClass")
public class CourseTechClassController extends BaseController
{
    @Autowired
    private ICourseTechClassService courseTechClassService;

    /**
     * 查询授课班级对应列表
     */
    @RequiresPermissions("course:courseTechClass:list")
    @GetMapping("/list")
    public TableDataInfo list(CourseTechClass courseTechClass)
    {
        startPage();
        List<CourseTechClass> list = courseTechClassService.selectCourseTechClassList(courseTechClass);
        return getDataTable(list);
    }

    /**
     * 导出授课班级对应列表
     */
    @RequiresPermissions("course:courseTechClass:export")
    @Log(title = "授课班级对应", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CourseTechClass courseTechClass)
    {
        List<CourseTechClass> list = courseTechClassService.selectCourseTechClassList(courseTechClass);
        ExcelUtil<CourseTechClass> util = new ExcelUtil<CourseTechClass>(CourseTechClass.class);
        util.exportExcel(response, list, "授课班级对应数据");
    }

    /**
     * 获取授课班级对应详细信息
     */
    @RequiresPermissions("course:courseTechClass:query")
    @GetMapping(value = "/{createBy}")
    public AjaxResult getInfo(@PathVariable("createBy") String createBy)
    {
        return success(courseTechClassService.selectCourseTechClassByCreateBy(createBy));
    }

    /**
     * 新增授课班级对应
     */
    @RequiresPermissions("course:courseTechClass:add")
    @Log(title = "授课班级对应", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CourseTechClass courseTechClass)
    {
        return toAjax(courseTechClassService.insertCourseTechClass(courseTechClass));
    }

    /**
     * 修改授课班级对应
     */
    @RequiresPermissions("course:courseTechClass:edit")
    @Log(title = "授课班级对应", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CourseTechClass courseTechClass)
    {
        return toAjax(courseTechClassService.updateCourseTechClass(courseTechClass));
    }

    /**
     * 删除授课班级对应
     */
    @RequiresPermissions("course:courseTechClass:remove")
    @Log(title = "授课班级对应", businessType = BusinessType.DELETE)
	@DeleteMapping("/{createBys}")
    public AjaxResult remove(@PathVariable String[] createBys)
    {
        return toAjax(courseTechClassService.deleteCourseTechClassByCreateBys(createBys));
    }
}
